import selectList from 'config/selectConfig';
import witdthList from 'config/widthConfig';
import sortList from 'config/sortConfig';
import showList from 'config/showConfig';
import specialList from 'config/specialConfig';
import iconList from 'config/iconConfig';
import imageList from 'config/imageConfig';

export function getSelectType(string) {
	if (string in selectList) {
		return selectList[string];
	}
	return [];
}

export function getConfig(type, key, value) {
	switch(type) {
		case 'width':
			return getIndexWidth(key);
		case 'sort':
			return getIndexSort(key);
		case 'word':
			return getWhether(key,value);
		case 'special':
		    return getSpecial(key);
		case 'icon':
			return getIcon(key);
		case 'image':
			return getImage(key, value);
	}
}

function getIndexWidth(str) {
	if(str in witdthList){
		return witdthList[str];
	}
	if (str.indexOf('num')) {
		return 100;
	}
	return 80;
}

function getIndexSort(str){
	if(sortList.indexOf(str) > -1) {
		return true;
	}
	if(str.indexOf('num') > -1) {
		return true;
	}
	return false;
}

function getWhether(key,value){
	if(key in showList) {
		return showList[key][Number(value)];
	}
	return value;
}

function getSpecial(key) {
	if(key in specialList) {
		return specialList[key];
	}
	return false;
}

function getIcon(key) {
	if(key in iconList) {
		return iconList[key];
	}
	return '';
}

function getImage(key, value){
	if(key in imageList){
		return imageList[key] + '/' + value;
	}
	return value === null ? '' : value;
}